<html>
    <head>
    <link rel="stylesheet" href="lmm.css" type="text/css" />
    </head>
<body class="lmm">
<!-- This file is part of the Lisp Machine manual.	-*-Text-*- -->

<div class='section'>4.1 The Lisp Top Level</div>
	These functions constitute the Lisp top level,
and its associated functions.

[This whole section needs to be rewritten.]

<div class='defun'><font class='exdent'><font class='funcname'>si:lisp-top-level
This <font class='italic' color='purple'>is the first function called in the initial Lisp environment.</font></font></font><br>
It calls <font class="lisp">lisp-reinitialize</font>, clears the screen, and calls <font class="lisp">si:lisp-top-level1</font>.
</div>

<div class='defun'><font class='exdent'><font class='funcname'>lisp-reinitialize
This <font class='italic' color='purple'>function does a wide variety of things, such as resetting the values</font></font></font><br>
of various global constants and initializing the error system.
</div>

<div class='defun'><font class='exdent'><font class='funcname'>si:lisp-top-level1
This <font class='italic' color='purple'>is the actual top level loop.  It prints out "<font class="lisp">105 FOOBAR</font>" and</font></font></font><br>
then goes into a loop reading a form from <font class="lisp">standard-input</font>,
evaluating it, and printing the result (with slashification) to
<font class="lisp">standard-output</font>.  If several values are returned by the form
all of them will be printed.  Also the values of <font class="lisp">*</font>, <font class="lisp">+</font>, <font class="lisp">-</font>, <font class="lisp">//</font>,
<font class="lisp">++</font>, <font class="lisp">**</font>, <font class="lisp">+++</font>, and <font class="lisp">***</font>
are maintained (see below).
</div>

<div class="defspec"><font class='exdent'><font class='funcname'>break</font><font class="italic"> Special Form</font></font><br>
<font class="lisp">break</font> is used to enter a breakpoint loop, which is similar
to a Lisp top level loop.  <font class="lisp">(break <font class="italic">tag</font>)</font> will always
enter the loop; <font class="lisp">(break <font class="italic">tag</font> <font class="italic">conditional-form</font>)</font>
will evaluate <font class="italic">conditional-form</font> and only enter the break loop
if it returns non-<font class="lisp">nil</font>.  If the break loop is entered, <font class="lisp">break</font>
prints out
<pre class="lisp">
;bkpt <font class="italic">tag</font>
</pre>
and then enters a loop reading, evaluating, and printing forms.
A difference between a break loop and the top level loop
is that after reading a form, <font class="lisp">break</font> checks for the
following special cases: if the symbol <font class="lisp">g</font> is typed,
<font class="lisp">break</font> throws back to the Lisp top level.  If <font class="lisp">p</font>
is typed, <font class="lisp">break</font> returns <font class="lisp">nil</font>.  If <font class="lisp">(return <font class="italic">form</font>)</font>
is typed, <font class="lisp">break</font> evaluates <font class="italic">form</font> and returns the result.
</div>

.defvar -
While a form is being evaluated by a read-eval-print loop,
<font class="lisp">-</font> is bound to the form itself.
.end_defvar

.defvar +
While a form is being evaluated by a read-eval-print loop,
<font class="lisp">+</font> is bound to the previous form that was read by the loop.
.end_defvar

.defvar *
While a form is being evaluated by a read-eval-print loop,
<font class="lisp">*</font> is bound to the result printed the last time through
the loop.  If there were several values printed (because
of a multiple-value return), <font class="lisp">*</font> is bound to the first
value.
.end_defvar

.defvar //
While a form is being evaluated by a read-eval-print loop,
<font class="lisp">//</font> is bound to a list of the results printed the last
time through the loop.
.end_defvar

.defvar ++
<font class="lisp">++</font> holds the previous value of <font class="lisp">+</font>, that is, the form evaluated
two interactions ago.
.end_defvar

.defvar +++
<font class="lisp">+++</font> holds the previous value of <font class="lisp">++</font>.
.end_defvar

.defvar **
<font class="lisp">**</font> holds the previous value of <font class="lisp">*</font>, that is, the result of the
form evaluated two interactions ago.
.end_defvar

.defvar ***
<font class="lisp">***</font> holds the previous value of <font class="lisp">**</font>.
.end_defvar

.defvar lisp-initialization-list
The value of <font class="lisp">lisp-initialization-list</font> is a list of forms, which
are sequentially evaluated by <font class="lisp">lisp-reinitialize</font>.
.end_defvar

.defvar lisp-crash-list
The value of <font class="lisp">lisp-crash-list</font> is a list of forms.
<font class="lisp">lisp-reinitialize</font> sequentially evaluates these
forms, and then sets <font class="lisp">lisp-crash-list</font> to <font class="lisp">nil</font>.
.end_defvar

<div class='section'>4.2 Logging In</div>
	Logging in tells the Lisp Machine who you are, so that
other users can see who is logged in, you can receive messages,
and your INIT file can be run.  An INIT file is a Lisp program
which gets loaded when you log in; it can be used to set up
a personalized environment.  The init file is named <font class="italic">user</font>; .LISPM (INIT)
if you have a directory.

	When you log out, it should be possible to undo any
personalizations you have made so that they do not affect the next user
of the machine.  Therefore, anything done by an INIT file should be
undoable.  In order to do this, for every form in the INIT file, a Lisp
form to undo its effects should be added to the list which is the value
of <font class="lisp">logout-list</font>.  The functions <font class="lisp">login-setq</font> and <font class="lisp">login-eval</font>
help make this easy; see below.

.defvar user-id
The value of <font class="lisp">user-id</font> is either the name of the logged in user, as a string,
or else an empty string if there is no user logged in.
It appears in the who-line.
.end_defvar

.defvar logout-list
The value of <font class="lisp">logout-list</font> is a list of forms which are evaluated
when a user logs out.
.end_defvar

<div class='defun'><font class='exdent'><font class='funcname'>login <font class='italic' color='purple'>name</font></font></font><br>
If anyone is logged into the machine, <font class="lisp">login</font> logs him out.
(See <font class="lisp">logout</font>.)
Then <font class="lisp">user-id</font> is set from <font class="italic">name</font>.
Finally <font class="lisp">login</font> attempts to find your INIT file.
It first looks in "<font class="italic">user-id</font>; .LISPM (INIT)",
then in "(INIT); <font class="italic">user-id</font> .LISPM",
and finally in the default init file "(INIT); * .LISPM".
When it finds one of these that exists, it loads it in.
<font class="lisp">login</font> returns <font class="lisp">t</font>.
</div>

<div class='defun'><font class='exdent'><font class='funcname'>logout
First, <font class="lisp"><font class='italic' color='purple'>logout</font> evaluates the forms on <font class="lisp">logout-list</font>.</font></font></font><br>
Then it tries to find a file to run, looking
first in "<font class="italic">user-id</font>; .LSPM_ (INIT)",
then in "(INIT); <font class="italic">user-id</font> .LSPM_",
and finally in the default file "(INIT); * .LSPM_".
If and when it finds one it these that exists, it loads it in.
Then it sets <font class="lisp">user-id</font> to an empty string and <font class="lisp">logout-list</font>
to <font class="lisp">nil</font>, and returns <font class="lisp">t</font>.
</div>

<div class="defspec"><font class='exdent'><font class='funcname'>login-setq</font><font class="italic"> Special Form</font></font><br>
<font class="lisp">login-setq</font> is like <font class="lisp">setq</font> except that it puts
a <font class="lisp">setq</font> form on <font class="lisp">logout-list</font> to set the variables
to their previous values.
</div>

<div class='defun'><font class='exdent'><font class='funcname'>login-eval <font class='italic' color='purple'>x</font></font></font><br>
<font class="lisp">login-eval</font> is used for functions which are "meant to be called"
from INIT files, such as <font class="lisp">eine:ed-redefine-keys</font>, which conveniently
return a form to undo what they did.  <font class="lisp">login-eval</font> adds
the result of the form <font class="italic">x</font> to the <font class="lisp">logout-list</font>.
</div>
.eof
</body>
</html>

